package com.miracle.common.state.user;

import android.content.Context;

import com.miracle.common.bean.User.User;
import com.miracle.common.util.PreferencesUtils;
import com.miracle.common.util.Utils;

import static com.miracle.common.util.Utils.getSafetyString;

/**
 * com.miracle.common.state.user
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/6/30 9:42
 * @see com.miracle.common.state.user
 */
public class LoginState implements UserState {

    @Override
    public void setUser(Context context, User user) {
        PreferencesUtils.setPreferences(context, PreferencesUtils.State.USER_NAME, user
                .getUserName());
        PreferencesUtils.setPreferences(context, PreferencesUtils.State.USER_ROLE, user
                .getRole());
        PreferencesUtils.setPreferences(context, PreferencesUtils.State.USER_SESSIONID, user
                .getJSESSIONID());
        PreferencesUtils.setPreferences(context, PreferencesUtils.State.USER_TEL, getSafetyString(user
                .getPhone()));
        PreferencesUtils.setPreferences(context, PreferencesUtils.State.USER_MAIL, getSafetyString(user
                .getEmail()));
        PreferencesUtils.setPreferences(context, PreferencesUtils.State.USER_SEX, getSafetyString(user
                .getSex()));
    }
}
